/*
 * @message: 描述
 * @Author: Roy
 * @Email: @163.com
 * @Github: @163.com
 * @Date: 2021-11-20 14:25:57
 * @LastEditors: Roy
 * @LastEditTime: 2021-11-21 21:28:24
 * @Deprecated: 否
 * @FilePath: /train-ticket/src/pages/index/store/reducer.js
 */
import * as actionTypes from './actionTypes'
const defaultState = {
    from: '北京',
    to: '上海',
    isCitySelectorVisible: false,
    currentSelectingLeftCity: false,
    cityData: null,//城市数据
    isLoadingCityData: false,//当前是否在加载城市
    isDateSelectorVisible: false,//日期选择开关
    highSpeed: false,//是否选择高铁 动车
    departDate: Date.now(),
};

// eslint-disable-next-line import/no-anonymous-default-export
export default (state = defaultState, action) => {
    let newState = JSON.parse(JSON.stringify(state));
    switch (action.type) {
        case actionTypes.SET_FROM:
            newState.from = action.payload;
            return newState;
        case actionTypes.SET_TO:
            newState.to = action.payload;
            return newState;
        case actionTypes.SET_IS_CITY_SELECTOR_VISIBLE:
            newState.isCitySelectorVisible = action.payload;
            return newState;
        case actionTypes.SET_CURRENT_SELECTING_LEFT_CITY:
            newState.currentSelectingLeftCity = action.payload;
            return newState;
        case actionTypes.SET_CITY_DATA:
            newState.cityData = action.payload;
            return newState;
        case actionTypes.SET_IS_LOADING_CITY_DATA:
            newState.isLoadingCityData = action.payload;
            return newState;
        case actionTypes.SET_IS_DATE_SELECTOR_VISIBLE:
            newState.isDateSelectorVisible = action.payload;
            return newState;
        case actionTypes.SET_HIGH_SPEED:
            newState.highSpeed = action.payload;
            return newState;
        case actionTypes.SET_DEPART_DATE:
            newState.departDate = action.payload;
            return newState;
        default:
            break;
    }
    return state;

}